/**
 * 数据字典
 */
import { axios } from '@/utils/request'

const api = {
  // todo
  dictClass: 'techdatadictionary', // 字典分类
  dictDetail: 'techdatadictionarydetail' // 字典明细
}
/**
 * 获取字典分类
 * @param {*} params
 */
export function getDictClassList (params) {
  return axios({
    url: api.dictClass + '/list',
    method: 'get',
    params
  })
}

export function getDictClassInfo (params) {
  return axios({
    url: api.dictClass + '/info',
    method: 'get',
    params
  })
}

export function addDictClass (data) {
  return axios({
    url: api.dictClass,
    method: 'post',
    data
  })
}

export function updateDictClass (data) {
  return axios({
    url: api.dictClass,
    method: 'put',
    data
  })
}

export function delDictClass (data) {
  return axios({
    url: api.dictClass,
    method: 'delete',
    data
  })
}

export function validateDictClassUnique (params) {
  return axios({
    url: api.dictClass + '/unique',
    method: 'get',
    params
  })
}

/**
 * 获取字典明细 --- 全局
 * @param {*} params
 */
export function getDictDetailList (params) {
  return axios({
    url: api.dictDetail + '/list',
    method: 'get',
    params
  })
}

/**
 * 获取字典明细 --- 根据字典分类id
 * @param {*} params
 */
export function getDictDetailListByClassId (params) {
  return axios({
    url: api.dictDetail + '/listByDataDictionaryId',
    method: 'get',
    params
  })
}

/**
 * 获取字典明细 --- 根据字典分类code
 * @param {*} params
 */
export function getDictDetailListByClassCode (params) {
  return axios({
    url: api.dictDetail + '/listByDataDictionaryCode',
    method: 'get',
    params
  })
}

export function addDictDetail (data) {
  return axios({
    url: api.dictDetail,
    method: 'post',
    data
  })
}

export function updateDictDetail (data) {
  return axios({
    url: api.dictDetail,
    method: 'put',
    data
  })
}

export function delDictDetail (data) {
  return axios({
    url: api.dictDetail,
    method: 'delete',
    data
  })
}

// 校验同一字典分类的字典明细key value 唯一
export function validateDictDetailUnique (params) {
  return axios({
    url: api.dictDetail + '/unique',
    method: 'get',
    params
  })
}
